#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
//int main()
//{
//	srand((unsigned int)time(NULL));
//		printf("%d\n", rand());
//		printf("%d\n", rand());
//		printf("%d\n", rand());
//		printf("%d\n", rand());
//		printf("%d\n", rand());
//		printf("%d\n", rand());
//		printf("%d\n", rand());
//		return 0;
//}

void menu()
{
	printf("***********************************\n");
	printf("*********    1.play    *************\n");
	printf("*********    2.exit    *************\n");
	printf("***********************************\n");
	printf("请选择：\n");
	
}
void game() 
{
	int r= rand()%100;
	int guess = 0;
	int count = 5;
	while (count>=0)
	{
		scanf("%d", &guess);
		if (guess < r)
			printf("猜小了,你还有%d次机会\n",count);
		else if (guess > r)
			printf("猜大了,你还有%d次机会\n",count);
		else if (guess == r)
		{
			printf("猜对了\n");
			break;
		}
		count--;
	}
}
int main() 
{
	int input = 0;
	srand((unsigned int)time(NULL));
	do 
	{
		menu();
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			printf("请猜数字\n");
			game();
			break;
		case 2:
			printf("退出游戏\n");
			break;
		default:
			printf("选择错误,重新选择\n");
			break;
		}
	}
	while (input);
	return 0;
}









